<?php
namespace AuctionCore\AuctionOrder;

/**
* 拍单功能 测试类
* @author       Eric Lee
*/
class AuctionOrderTest extends \PHPUnit_Framework_TestCase {

    private $emp_id = '197';	
    //创建拍单
    public  function testCreate(){
            $au = new AuOrder(1);
            $order = array();
            $order['car_id'] = '1';
            $order['emp_id'] = '1';
            $order['scene_id'] = '2';
            $order['bid_start_time'] = '2015-12-10 12:12:12';
            $order['bidding_start_time'] = '2015-12-10 13:13:13';
            $order['bidding_end_time'] = '2015-12-10 14:14:14';
            $order['success_price'] = '100,990.00';
            $order['status'] = '1';
            $order['fail_type'] = '1';
            $order['commision'] = '1000';
            $order['transfer_fee'] = '1000';
            $order['trade_time'] = '2015-12-10 10:22:30';
            $order['pay_type'] = '1';
            $order['deliver_type'] = '1';
            $order['remark'] = '备注信息';
            $order['bid_start_price'] = '80000.00';
            $order['bid_best_price'] = '90000.00';
            $order['bidding_best_price'] = '100,990.00';
            $order['dealer_confirm_status'] = '1';
            $order['is_self_confirm'] = '1';
            $order['last_time'] = date('Y-m-d H:i:s');
            $order['create_time'] = date('Y-m-d H:i:s');

            try{
                $res = $au->create(1,$order);
            }catch(\Exception $e){
                $e->getMessage();
                $res = false;
            }

           $this->assertTrue($res?true:false);
    }
    //车主前台自主确认成交
    public  function testConfirmTrade(){
            $au = new AuOrder('6');
            $res = $au->confirm_trade();
            $this->assertTrue($res?true:false);
    }
    //获取详细
    public  function testDetail(){
            $au = new AuOrder('6');
            $res = $au->detail();
            dump($res,true,null,false);
            $this->assertTrue($res?true:false);
    }
    //审核成功
    public  function testAuditSuccess(){
            $au = new AuOrder('6');
            $data = array();
            $data['emp_id'] = $this->emp_id;
            $res = $au->audit_success($data);
            $this->assertTrue($res?true:false);
    }
    //审核驳回
    public  function testAuditReject(){
            $au = new AuOrder('6');
            $data = array();
            $data['emp_id'] ='1';
            $data['f'] ='1';
            $data['remark_reject'] ='remark here.The reject reason.';

            $res = $au->audit_reject($data);
            $this->assertTrue($res?true:false);
    }
    //投标出价
    public  function testBidPrice(){
            $au = new AuOrder('6');
            $res = $au->bid_price('3','80500');
            $this->assertTrue($res?true:false);
    }
    //开始竞标
    public  function testStartBidding(){            
            $au = new AuOrder(6);
            $au->start_bidding();
    }
    //竞标出价
    public  function testBiddingPrice(){            
            $au = new AuOrder(6);
            $dealer_id = '22';
            $org_price = '600';
            $add_price = 500;
            $ok = $au->bidding_price($dealer_id, $org_price, $add_price) ;
            $this->assertTrue($ok);

    }
    //结束竞标
    public  function testEndBidding(){            
            $au = new AuOrder(6);
            $au->end_bidding();
    }
    //开始过户
    public  function testStartTrade(){
            $au = new AuOrder('6');
            $data = array();
            $data['order_id'] = '6';
            $data['emp_id'] = '1';
            $data['company'] = '北京千页汽配公司';
            $data['phone'] = '15921306031';
            $data['contact'] = '李休渔';
            $data['idcard'] = '130481197908062879';
            $data['remark'] = 'remark here.';

            $res = $au->start_trade($data);
            $this->assertTrue($res?true:false);
    }
    //更新拍单状态
    public  function testUpdateStatus(){
            $au = new AuOrder('6');
            $emp_id = '197';
            $res = $au->update_status($emp_id);
            $this->assertTrue($res?true:false);
    }
    //支付首款
    public  function testPayFirst(){
            $au = new AuOrder('6');
            $emp_id = '197';
            $res = $au->pay_first($emp_id);
            $this->assertTrue($res?true:false);
    }
    //支付尾款
    public  function testPayTail(){
            $au = new AuOrder('6');
            $data = array();
            $data['emp_id'] = '197';
            $res = $au->pay_tail($data);
            $this->assertTrue($res?true:false);
    }
    //更新拍单表
    public  function testUpdate(){
            $au = new AuOrder('6');
            $data = array();
            $data['success_price'] = '170000';
            $res = $au->update($data);
            $this->assertTrue($res?true:false);
    }
    //确认收款
    public  function testConfirmProceeds(){
            $au = new AuOrder('6');
            $data = array();
            $data['emp_id'] = '197';
            $data['payer_name'] = '王伯当';
            $data['pay_bank'] = '中国建设银行新街口支行';
            $data['payer_account'] = '4367420011190126621';
            $data['pay_time'] = date('Y-m-d H:i:s');
            $res = $au->confirm_proceeds($data);
            $this->assertTrue($res?true:false);
    }
    //全局跟踪日志
    public function testTraceLog(){
            $au = new AuOrder('6');
            $res = $au->trace_log();

/*            foreach(C('BUSINESS_STATUS') as $s){
                    $data = array();
                    $data['result'] = $s;
                    $data['createtime'] = date('Y-m-d H:i:s');
                    M('global_log')->add($data);
            }
            foreach(C('ORDER_STATUS') as $s){
                    $data = array();
                    $data['emp_id'] = '1';
                    $data['result'] = $s;
                    $data['createtime'] = date('Y-m-d H:i:s');
                    M('global_log')->add($data);
            }
            foreach(C('CAR_STATUS') as $s){
                    $data = array();
                    $data['result'] = $s;
                    $data['createtime'] = date('Y-m-d H:i:s');
                    M('global_log')->add($data);
            }
            M()->query("update au_global_log set owner_id='1',car_id='1',order_id='1',dealer_id='1',emp_id='1' where 1=1");
            */
            dump($res,true,null,false);
            $this->assertTrue($res?true:false);
    }


}

?>